//切片文件，一个切片保存着一组数据
import { createSlice ,createAsyncThunk} from '@reduxjs/toolkit'

import {getAsyncInfo} from '../../server'

export const fetchStudent = createAsyncThunk('student/fetchStudent',async () => {
    let data = await getAsyncInfo(); 
    console.log(data)
    return data.data; 
})

const studentSlice = createSlice({ 
    name: 'student', 
    initialState:{ 
        student:{} ,

    },
	extraReducers(builder) { 
		builder.addCase(fetchStudent.fulfilled, (state, action) => { 
            state.student = action.payload; 
        }) 
    } 
}) 
//层次不同，导出最好用不同的方式导出
export default studentSlice.reducer
